Skip to content

GH-1548: [JDBC] Read offset time zones of timestamps and treat an empty time zone as unset - #1549

Open
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:gh-1548-timestamp-offset-timezones
Open

jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:gh-1548-timestamp-offset-timezones

Conversation

@jbonofre

@jbonofre jbonofre commented Dec 3, 2026

Copy link
Copy Markdown
Member

What's Changed

Follow-up to #1542.

  • ArrowFlightJdbcTimeStampVectorAccessor applies a time zone given as an offset, such as +03:00, -05:30, +0300 or UTC+3. Before, TimeZone.getTimeZone turned these into GMT, so getObject(LocalDateTime/OffsetDateTime), getTimestamp, getDate and getTime were off by the offset, and a LocalDateTime bound with setObject did not read back unchanged.
    • A name is only parsed with ZoneId.of(name, ZoneId.SHORT_IDS), as the parameter converter does, when TimeZone.getTimeZone does not know it. Names it knows are parsed as before. For all 632 IDs of TimeZone.getAvailableIDs(), both give the same offsets on JDK 17, 21 and 25, so reading and binding agree for those too.
    • A name neither knows, such as utc, is still read as GMT, so reading a result set doesn't start failing. Binding a parameter with such a name still fails, as since GH-1540: Bind TIMESTAMP parameters in the vector unit and accept java.time values in Flight SQL JDBC #1542.
  • A timestamp with an empty time zone is handled like one without a time zone, as the Arrow format specifies ("Timestamps with an unset / empty timezone") and as SqlTypes already reports it (TIMESTAMP).
    • Reading: getObject(Instant/OffsetDateTime/ZonedDateTime) now throws SQLException, as for a column without a time zone. The other getters return the same values as for a column without a time zone, which in the tests are also the values they returned before.
    • Binding: setObject(i, LocalDateTime) binds the wall-clock time as UTC, as for a parameter without a time zone, instead of failing with DateTimeException. Instant, OffsetDateTime and ZonedDateTime are rejected, as for a parameter without a time zone.

This contains breaking changes: values read from columns with an offset time zone change (they were wrong), and Instant, OffsetDateTime and ZonedDateTime can no longer be read from a column with an empty time zone.

Tests

  • ArrowFlightJdbcTimeStampVectorAccessorTest: offset time zones through getObject(LocalDateTime/Instant/OffsetDateTime) and getTimestamp. An empty time zone reads like no time zone, with and without a calendar. Unknown names (Not/AZone, utc) are still read as GMT.
  • TimestampAvaticaParameterConverterTest: binding to a parameter with an empty time zone, and a LocalDateTime bound and read back through the accessor in every unit, for no, empty, named (UTC, America/New_York, EST) and offset time zones.

The new tests fail on main (14 failures), except the unknown-name tests, which check behaviour that doesn't change. The flight-sql-jdbc-core build passes on JDK 17, including checkstyle, and the two test classes pass on JDK 21 and 25. spotless:check passes.

Closes #1548.

…an empty time zone as unset

Parse a timestamp time zone that TimeZone.getTimeZone does not know,
such as "+03:00", with ZoneId, as the parameter converter does, instead
of reading the vector as GMT. Names that TimeZone.getTimeZone knows are
parsed as before, and unknown names are still read as GMT.

Treat an empty time zone like an unset one when reading and binding, as
the Arrow format specifies and as SqlTypes already reports it.

Closes apache#1548.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flight SQL JDBC] Timestamp time zones given as an offset are read as GMT, and an empty time zone is treated as a time zone

1 participant